{include file="header" }
{include file="sibar" }
<div class="main-content">
    <div class="main-content-inner">
        <div class="breadcrumbs breadcrumbs-fixed" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="{:U('index/index')}">首页</a>
                </li>
                <li>
                    <a href="{:U('index')}">商品管理</a>
                </li>
                <li>
                    <span>编辑商品</span>
                </li>
            </ul>
        </div>
        <div class="page-content">
            <div class="page-header">
                <h1>编辑商品</h1>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <form>
                        <div class="form-group">
                            <label for="gc_name">分类名称</label>
                            <input type="text" class="form-control" id="gc_name" placeholder="分类名称">
                        </div>
                        <div class="form-group">
                            <label for="show_type">商品展示方式</label>
                            <select class="form-control" id="show_type">
                                <option value="1">颜色</option>
                                <option value="2">SPU</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="type_name">上级分类</label>
                            <select class="form-control" id="type_name">
                                <option value="0">请选择</option>
                                {foreach $goods_class_list as $item}
                                <option value="{$item.gc_id}">{$item.gc_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="gc_sort">排序</label>
                            <input type="text" class="form-control" value="0" id="gc_sort" placeholder="排序">

                        </div>
                        <p>
                            <a id="save" class="btn btn-primary btn-sm">确认提交</a>
                            <a href="#" class="btn btn-sm domall-back">返回</a>
                        </p>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('#save').click(function(){
            if($('#gc_name').val()==''){
                alert('分类名称不能为空');
                return;
            }
            var data = {
                gc_name:$('#gc_name').val(),
                show_type:$('#show_type').val(),
                type_id:$('#type_name').val(),
                type_name:$("#type_name").find("option:selected").text(),
                gc_sort:$('#gc_sort').val()
            };
            $.post('/admin/goods_class/edit', data, function(info){
                if(info.code = 1){
                    location.href=info.url;
                }else{
                    alert(info.msg);
                }
            });
        });

    });
</script>

{include file="footer" }